﻿using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.下单MTO
{
    public partial class FormMTO新建客户量体 : DevExpress.XtraEditors.XtraForm
    {
        private List<CustomerFitRDTO量体值> customerFitRDTOs = new List<CustomerFitRDTO量体值>();
        private String mobile;
        public FormMTO新建客户量体()
        {
            InitializeComponent();
        }
        public FormMTO新建客户量体(String mobile)
        {
            InitializeComponent();
            this.mobile = mobile;
            this.loadText();
        }
        private void loadText()
        {
            this.customerFitRDTOs = MTO订单Service.getCustomerFitRDTOsByMobile(this.mobile);
            if (this.customerFitRDTOs == null)
            {
                return;
            }
            foreach (CustomerFitRDTO量体值 customerFit in this.customerFitRDTOs)
            {
                switch (customerFit.itemValue)
                {
                    case "FITMT_ITEM_09":
                        this.textBox身高.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_10":
                        this.textBox体重.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_02":
                        this.textBox胸围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_05":
                        this.textBox肩宽.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_12":
                        this.textBox腰围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_03":
                        this.textBox臀围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_04":
                        this.textBox身长.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_01":
                        this.textBox领围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_08":
                        this.textBox腕围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_06":
                        this.textBox袖长.Text = customerFit.fitValue;
                        break;
                    case "FITMT_ITEM_07":
                        this.textBox大臂围.Text = customerFit.fitValue;
                        break;
                    case "FITMT_CODE_03":
                        switch (customerFit.fitValue)
                        {
                            case "CD03_07":
                                this.comboBox体型.SelectedItem = "正常";
                                break;
                            case "CD03_08":
                                this.comboBox体型.SelectedItem = "中肚";
                                break;
                            case "CD03_09":
                                this.comboBox体型.SelectedItem = "大肚";
                                break;
                            case "CD03_10":
                                this.comboBox体型.SelectedItem = "后腰空";
                                break;
                        }
                        break;
                    case "FITMT_CODE_01":
                        switch (customerFit.fitValue)
                        {
                            case "1":
                                this.comboBox肩型.SelectedItem = "平肩";
                                break;
                            case "2":
                                this.comboBox肩型.SelectedItem = "溜肩";
                                break;
                            case "3":
                                this.comboBox肩型.SelectedItem = "正常";
                                break;
                            case "4":
                                this.comboBox肩型.SelectedItem = "冲肩";
                                break;
                        }
                        break;
                    case "FITMT_CODE_09":
                        switch (customerFit.fitValue)
                        {
                            case "CD09_01":
                                this.comboBox胸型.SelectedItem = "正常";
                                break;
                            case "CD09_02":
                                this.comboBox胸型.SelectedItem = "驼背";
                                break;
                            case "CD09_03":
                                this.comboBox胸型.SelectedItem = "挺胸";
                                break;
                            case "CD09_04":
                                this.comboBox胸型.SelectedItem = "丰满胸";
                                break;
                        }
                        break;
                    case "FITMT_CODE_08":
                        switch (customerFit.fitValue)
                        {
                            case "CD08_01":
                                this.comboBox喜好.SelectedItem = "标准";
                                break;
                            case "CD08_02":
                                this.comboBox喜好.SelectedItem = "超修";
                                break;
                            case "CD08_03":
                                this.comboBox喜好.SelectedItem = "宽松";
                                break;
                        }
                        break;
                }
            }
        }

        private void simpleButton保存_Click(object sender, EventArgs e)
        {
            this.customerFitRDTOs = new List<CustomerFitRDTO量体值>();
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_09",
                String.IsNullOrEmpty(this.textBox身高.Text) ? "0" : this.textBox身高.Text,
                "身高",
                "",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_10",
                String.IsNullOrEmpty(this.textBox体重.Text) ? "0" : this.textBox体重.Text,
                "体重",
                "",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_02",
                String.IsNullOrEmpty(this.textBox胸围.Text) ? "0" : this.textBox胸围.Text,
                "胸围",
                "CIRCU_ITEM_02",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_05",
                String.IsNullOrEmpty(this.textBox肩宽.Text) ? "0" : this.textBox肩宽.Text,
                "肩宽",
                "CIRCU_ITEM_07",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_12",
                String.IsNullOrEmpty(this.textBox腰围.Text) ? "0" : this.textBox腰围.Text,
                "腰围",
                "CIRCU_ITEM_05",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_03",
                String.IsNullOrEmpty(this.textBox臀围.Text) ? "0" : this.textBox臀围.Text,
                "臀围",
                "CIRCU_ITEM_06",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_04",
                String.IsNullOrEmpty(this.textBox身长.Text) ? "0" : this.textBox身长.Text,
                "身长",
                "LENGT_ITEM_02",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_01",
                String.IsNullOrEmpty(this.textBox领围.Text) ? "0" : this.textBox领围.Text,
                "领围",
                "FITMT_ITEM_01",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_08",
                String.IsNullOrEmpty(this.textBox腕围.Text) ? "0" : this.textBox腕围.Text,
                "腕围",
                "CIRCU_ITEM_17,CIRCU_ITEM_18",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_06",
                String.IsNullOrEmpty(this.textBox袖长.Text) ? "0" : this.textBox袖长.Text,
                "臂长",
                "POSTU_ITEM_07,POSTU_ITEM_09",
                ""));
            this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                "FITMT_ITEM_07",
                String.IsNullOrEmpty(this.textBox大臂围.Text) ? "0" : this.textBox大臂围.Text,
                "臂根围",
                "LENGT_ITEM_08",
                ""));
            if (!String.IsNullOrEmpty(this.comboBox体型.Text.Trim()))
            {
                switch (this.comboBox体型.Text.Trim())
                {
                    case "正常":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_07",
                        "体型",
                        "",
                        "正常"));
                        break;
                    case "中肚":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_08",
                        "体型",
                        "",
                        "中肚"));
                        break;
                    case "大肚":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_09",
                        "体型",
                        "",
                        "大肚"));
                        break;
                    case "后腰空":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_03",
                        "CD03_10",
                        "体型",
                        "",
                        "后腰空"));
                        break;
                }
            }
            if (!String.IsNullOrEmpty(this.comboBox肩型.Text.Trim()))
            {
                switch (this.comboBox肩型.Text.Trim())
                {
                    case "平肩":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "1",
                        "肩型",
                        "",
                        "平肩"));
                        break;
                    case "溜肩":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "2",
                        "肩型",
                        "",
                        "溜肩"));
                        break;
                    case "正常":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "3",
                        "肩型",
                        "",
                        "正常"));
                        break;
                    case "冲肩":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_01",
                        "4",
                        "肩型",
                        "",
                        "冲肩"));
                        break;
                }
            }
            if (!String.IsNullOrEmpty(this.comboBox胸型.Text.Trim()))
            {
                switch (this.comboBox胸型.Text.Trim())
                {
                    case "正常":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_01",
                        "胸型",
                        "",
                        "正常"));
                        break;
                    case "驼背":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_02",
                        "胸型",
                        "",
                        "驼背"));
                        break;
                    case "挺胸":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_03",
                        "胸型",
                        "",
                        "挺胸"));
                        break;
                    case "丰满胸":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_09",
                        "CD09_04",
                        "胸型",
                        "",
                        "丰满胸"));
                        break;
                }
            }
            if (!String.IsNullOrEmpty(this.comboBox喜好.Text.Trim()))
            {
                switch (this.comboBox喜好.Text.Trim())
                {
                    case "标准":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_08",
                        "CD08_01",
                        "喜好",
                        "",
                        "标准"));
                        break;
                    case "超修":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_08",
                        "CD08_02",
                        "喜好",
                        "",
                        "超修"));
                        break;
                    case "宽松":
                        this.customerFitRDTOs.Add(new CustomerFitRDTO量体值(
                        "FITMT_CODE_08",
                        "CD08_03",
                        "喜好",
                        "",
                        "宽松"));
                        break;
                }
            }
            try
            {
                if (MTO订单Service.saveCustomerFitRByMobile(this.mobile, this.customerFitRDTOs) != null)
                {
                    MessageBox.Show("保存成功");
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存失败" + ex.Message);
            }
        }
    }
}
